package com.droowa.model.dao;

import java.sql.SQLException;
import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.droowa.domain.DeliveryEnterpriseManagement;

@Repository
public class DeliveryEnterpriseManagementDAOMybatisImpl implements DeliveryEnterpriseManagementDAO{

	@Autowired
	private SqlSessionTemplate session;
	
	@Override
	public int insertDeliveryEnterpriseManagement(
			DeliveryEnterpriseManagement deliveryEnterpriseManagement)
			throws SQLException {
		return session.insert(makeSqlId("insertDeliveryEnterpriseManagement"), deliveryEnterpriseManagement);
	}

	@Override
	public int deleteDeliveryEnterpriseManagement(String deliveryEnterpriseId)
			throws SQLException {
		return session.delete(makeSqlId("deleteDeliveryEnterpriseManagement"), deliveryEnterpriseId);
	}

	@Override
	public int updateDeliveryEnterpriseManagement(
			DeliveryEnterpriseManagement deliveryEnterpriseManagement)
			throws SQLException {
		return session.update(makeSqlId("updateDeliveryEnterpriseManagement"), deliveryEnterpriseManagement);
	}

	@Override
	public DeliveryEnterpriseManagement selectDeliveryEnterpriseManagementByDeliveryEnterpriseId(
			int deliveryEnterpriseId) throws SQLException {
		return session.selectOne(makeSqlId("selectDeliveryEnterpriseManagementByDeliveryEnterpriseId"), deliveryEnterpriseId);
	}

	@Override
	public List<DeliveryEnterpriseManagement> selectDeliveryEnterpriseManagementByEnterpriseName(
			String enterpriseName) throws SQLException {
		return session.selectList(makeSqlId("selectDeliveryEnterpriseManagementByEnterpriseName"), enterpriseName);
	}

	@Override
	public List<DeliveryEnterpriseManagement> selectDeliveryEnterpriseManagementByTel(
			String tel) throws SQLException {
		return session.selectList(makeSqlId("selectDeliveryEnterpriseManagementByTel"), tel);
	}

	@Override
	public List<DeliveryEnterpriseManagement> selectDeliveryEnterpriseManagementByEmail(
			String email) throws SQLException {
		return session.selectList(makeSqlId("selectDeliveryEnterpriseManagementByEmail"), email);
	}

	@Override
	public List<DeliveryEnterpriseManagement> selectDeliveryEnterpriseManagement()
			throws SQLException {
		System.out.println(session.selectList(makeSqlId("selectDeliveryEnterpriseManagement")));
		return session.selectList(makeSqlId("selectDeliveryEnterpriseManagement"));
	}

	private String makeSqlId(String id){
		return "droowa.deliveryEnterpriseManagement."+id;
	}
	
}
